package com.bupt.liutong.front.groupon.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.beans.factory.annotation.Autowired;

import com.bupt.liutong.admin.core.base.BaseAction;
import com.bupt.liutong.admin.groupon.bo.CityBo;
import com.bupt.liutong.admin.groupon.bo.GrouponBo;
import com.bupt.liutong.admin.groupon.form.GrouponForm;

public class GrouponAction extends BaseAction {
	
	@Autowired
	private GrouponBo grouponBo;
	
	@Autowired
	private CityBo cityBo;

	public ActionForward list(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		GrouponForm grouponForm = (GrouponForm) form;
		Integer cityId = cityBo.getCityId(request, response);
		grouponForm.setCityId(cityId);
		request.setAttribute("cityId", cityId);
		request.setAttribute("grouponList", grouponBo.list(grouponForm));
		putPageInfo(request, grouponForm);
		return mapping.findForward("list");
	}

	public void setGrouponBo(GrouponBo grouponBo) {
		this.grouponBo = grouponBo;
	}

	public void setCityBo(CityBo cityBo) {
		this.cityBo = cityBo;
	}
}
